<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      var data = 10;
      var arr = [1, 3, 24, 3];
      function exist(data, arr) {
        var flag = false; //设置一个变量表示在这个数组中不存在这个shuju
        for (var i = 0; i < arr.length; i++) {
          if (data == arr[i]) {
            flag = true;
          }
        }
        return flag;
      }
      console.log(exist(data, arr));
    </script>
  </body>
</html>
